package wifiunion.com.notice.presenter;

import android.content.Context;


import java.util.HashMap;

import wifiunion.com.notice.ConfigureContact;
import wifiunion.com.notice.ConfigureModel;

/**
 * Created by Administrator on 2016/11/23.
 */

public class NoticeBackgroundPresenter implements ConfigureContact.Presenter, ConfigureContact.Callback {

    private ConfigureContact.NoticeBackgroundView mView;
    private Context mContext;
    private ConfigureModel mModel;
    /**
     * 0
     * 1
     * 2
     * 3
     * 4
     * 5
     * 6
     */
    private int mType ;


    private HashMap<String,Object> param = new HashMap<>();


    public NoticeBackgroundPresenter(Context context, ConfigureContact.NoticeBackgroundView view, int type) {
        mView = view;
        mContext = context;
        mModel = new ConfigureModel();
        mView.setPresenter(this);
        mType = type;
    }

    @Override
    public void onSuccess(Object data) {

        switch (mType)
        {
            case 1:
                mView.getNoticeBackgroundSuccess(data);
            break;
            case 2:
                mView.updateNoticeBackgroundSuccess(data);
                break;

        }

    }

    @Override
    public void onServerFailed(Object errorObj) {

        switch (mType)
        {
            case 1:
                mView.getNoticeBackgroundFailed((String)errorObj);
                break;
            case 2:
                mView.updateNoticeBackgroundailed((String)errorObj);
                break;

        }
    }

    @Override
    public void onNetFailed() {
        switch (mType)
        {
            case 1:
                mView.getNoticeBackgroundFailed("网络异常");
                break;
            case 2:
                mView.updateNoticeBackgroundailed("网络异常");
                break;

        }

    }

    @Override
    public void start() {

    }

    @Override
    public void start(HashMap<String, Object> params) {

    }

    public void getNoticeBackground(HashMap<String, Object> param1s) {
        mModel.getNoticeBackground(param1s, this);
    }

    public void updateNoticeBackground(HashMap<String, Object> param1s) {
        mModel.updateNoticeBackground(param1s, this);
    }

}
